/**
 * 简单表格 视图控制
 */
Ext.define('Jason.view.example.grid.basic.MainController', {
    extend: 'Wys.basic.BaseCtrl',
    alias: 'controller.basicGridViewCtrl',

    onNewButtonClick: function (btn) {
        Ext.create('Wys.form.FormWindow', {
            width: 380,
            height: 250,
            model: '',
            config: {
                operatetype: 'new',
                items: [
                    { xtype: 'textfield', fieldLabel: '字段1' },
                    { xtype: 'textfield', fieldLabel: '字段2' }
                ]
            }
        }).show()
    },

    onDeleteButtonClick: function (btn) {
        Ext.Msg.confirm({
            title: "请确认",
            message: '您确定要删除所选数据？',
            buttons: Ext.Msg.YESNO,
            fn: function (btn) {
                if (btn === 'yes') {
                    //点击确认事件
                } else {

                }
            }
        });
    },

    onGridCommand: function (item, command, record, recordIndex, cellIndex) {
        var me = this;
        if (command === 'modify') {/** 修改 */
            Ext.create('Wys.form.FormWindow', {
                width: 400,
                height: 250,
                model: '',
                config: {
                    operatetype: 'edit',
                    items: [
                        { xtype: 'textfield', fieldLabel: '字段1' },
                        { xtype: 'textfield', fieldLabel: '字段2' }
                    ]
                }
            }).show();
        }
        if (command === 'preview') {
            Ext.create('Wys.form.FormWindow', {
                width: 400,
                height: 250,
                model: '',
                config: {
                    operatetype: 'display',
                    items: [
                        { xtype: 'textfield', fieldLabel: '字段1' },
                        { xtype: 'textfield', fieldLabel: '字段2' }
                    ]
                }
            }).show();
        }
        if (command === 'remove') {/** 删除*/
            me.onDeleteButtonClick(item);
        }
    },
    onGridRepareCommands: function (self, gridRef, commands, record, row) {
        //这里可以去控制操作按钮的显示隐藏
    }

});